package com.controller;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.entity.User;

@Controller
public class UserController {
	
	@RequestMapping("/login")
	public String login(HttpSession session,@RequestParam("name")String name,@RequestParam("password")String password){
		List<User> list=new ArrayList<>();
		User u=new User();
		u.setName("siggy");
		u.setPwd("1111");
		list.add(u);
		
		if(name.equals(list.get(0).getName())&&password.equals(list.get(0).getPwd())){
			session.setAttribute("user", list.get(0));
			return "redirect:/index.jsp";
		}else{
		    return "redirect:/login.jsp";
		}
	}
}
